#coding:utf-8
import os
from common.koufuApi import KoufuApi
from common.koufuShopApi import KoufuShopApi

__author__ = 'yangxianming'

from common.KoufuConf import KoufuConf
import json
import requests


def case():
    #初始化必要的参数
    kou_fu_conf = KoufuConf()
    test_url = kou_fu_conf.koufu_test_domain + "/api/koufu"
    kou_fu_shop_api = KoufuShopApi()
    kou_fu_api = KoufuApi()
    kou_fu_shop_api = KoufuApi()
    script_name = os.path.basename(__file__)
    tf = True
    test_result = ""

    try:
        #餐规列表
        p = kou_fu_api.get_efuli_koufu_mealrule_query_data(update_body={"pageSize":100})
        r = requests.post(test_url, data=json.dumps(p), headers=kou_fu_conf.headers)
        rData = r.json()["return_data"]
        print("这个是接口get_efuli_koufu_mealrule_query_data返回的全部参数",  rData)

        for data in rData:
            m_id = data["mealRuleId"]
            print(m_id)
            p1 = kou_fu_api.get_efuli_koufu_mealrule_onoff_data(update_body={"mealRuleId":m_id})
            rr = requests.post(test_url, data=json.dumps(p1), headers=kou_fu_conf.headers)
            print("这个是接口get_efuli_koufu_mealrule_onoff_data返回的全部参数",  rr.json())


        #具体判断
        # if voucherId is not None:
        #     tf = False
    except Exception as e:
        err_info = str(e).replace("'", "").replace("\"", "")
        test_result = "非预期的异常,脚本文件:" + script_name + "; 错误信息：" + err_info
        tf = -2

    #定义预期描述
    print(str(tf))
    print(test_result)
    expect_result = "返回参数ebuyCode是否是空"

    #返回测试结果 第一个参数:True or False    第二个参数测试结果描述
    return tf, [test_result, expect_result]

case()